import sys

from PyQt5.QtCore import Qt
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QLineEdit, QPushButton, QMessageBox, QFrame, QSpinBox, \
    QHBoxLayout, QDoubleSpinBox, QWidget

'''

数值（整数QSpinBox、小数QDoubleSpinBox）调整
1、可添加前缀、后缀
2、可直接输入
3、可点击按钮上下微调
'''


class MyClass(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        self.setWindowTitle('刘金玉编程教程')
        self.setWindowIcon(QIcon('./img/msn.ico'))
        self.setGeometry(800, 370, 400, 300)

        hlo = QHBoxLayout(self)
        sb = QSpinBox(self)
        sb.setRange(0, 10)
        sb.setPrefix("物品 ")
        sb.setSuffix(" 件")

        hlo.addWidget(sb)
        hlo.setAlignment(Qt.AlignTop)  # 设置对齐方式

        dsb = QDoubleSpinBox(self)
        dsb.setRange(0, 100)
        dsb.setSingleStep(0.05)
        dsb.setPrefix('单价 ')
        dsb.setSuffix(' 元')

        hlo.addWidget(dsb)

        self.show()

    def myDo(self):
        pass


if __name__ == '__main__':
    app = QApplication(sys.argv)
    myf = MyClass()
    app.exec_()
